package svgedit.gui.commands;

import svgedit.svg.SVGDocument;
import svgedit.svg.SVGElement;

/**
 * Handles the undo and redo for inserting elements to the document
 * 
 * @author SARJ
 * 
 */
public class InsertCommand implements Command
{
	private SVGElement element;
	private SVGDocument document;

	/**
	 * Constructs the insert command to perform its undo redo actions
	 * @param document The document which the element will be inserted to
	 * @param element The element to insert
	 */
	public InsertCommand(SVGDocument document, SVGElement element)
	{
		this.document = document;
		this.element = element;
	}

	@Override
	public void executeUndo()
	{
		element.getParent().removeChild(element);
	}

	@Override
	public void executeRedo()
	{
		document.getRootGroup().appendChild(element);

	}

}
